const { ccclass, property } = cc._decorator;
/** 拖拽组件 */
@ccclass
export default class DragComp extends cc.Component {
    /** 拖拽起始点 */
    private dragStartPos: cc.Vec2 = cc.Vec2.ZERO;

    //#region 声明周期

    onLoad() {
        this.initEvent();
    }

    //#endregion

    private initEvent() {
        this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
    }

    //#region 回调函数

    private onTouchStart(e: cc.Event.EventTouch) {
        
    }

    private onTouchMove(e: cc.Event.EventTouch) {
        let touchPos = e.getLocationInView();
        this.node.setPosition(touchPos.x - cc.winSize.width / 2, -touchPos.y + cc.winSize.height / 2);
    }


    private onTouchEnd(e: cc.Event.EventTouch) {

    }

    //#endregion
}
